<div class="search index">
<h2><?php __('What do you want to search?'); ?></h2>

<!-- Print Search form -->
<div class="searcher form">
<?php e($form->create('SearchIndex', array('url' => array('controller' => 'search_indexes', 'action' => 'index')))); ?>
    <fieldset>
        <?php e($form->input('type', array(
            'label'=>false, 'class'=>'select', 'empty' => 'All',
            'title' =>'选择1个类别, 目前可以搜索的内容包括公告, 职位, 公司等信息, 选择All搜索所有')
        )); ?>
        <?php e($form->input('term', array(
            'label' => false, 'id' => 'SearchSearch', 'class' => 'input text', 'value'=>$term,
            'title' =>'输入检索关键字, 公司名称, 职位名称, 公告的相关内容, 地区名称或其他您感兴趣的话题, 使用逗号分隔多个关键词, 如键入"北京, 公司"搜索所有北京的公司')
        )); ?>
        <?php e($form->submit(__('Search', true), array('class' => 'submit attention', 'style'=>'clear:none'))); ?>
        <a href="javascript:void(0)" id="load_tag_cloud"><?php __('Tag Cloud'); ?></a>
    </fieldset>
<?php e($form->end()); ?>
</div>

<!-- Ajax tag cloud -->
<div id="tag_cloud"></div>

<!-- Print search results -->
<div class="results">
<?php //debug($results); ?>
<?php if (!empty($results)): ?>
    <?php $pager =$this->element('pager', array('extra_params'=>array('type', 'term'))); ?>
    <?php echo $pager; ?><br class="clear"/>
        <?php foreach($results as $result): ?>
            <div class="item <?php e(strtolower($result['SearchIndex']['model'])); ?>">
                <?php e($searchable->parseResult($result['SearchIndex'])); ?>
            </div>
        <?php endforeach; ?>
    <br class="clear"/>
    <?php echo $pager; ?>
<?php elseif(!empty($term)): ?>
    <p>
        <?php __('Sorry, your search did not return any matches'); ?>
    </p>
<?php else: ?>
    <p>
        <?php __('Choose an item, type in your keywords and press the search button'); ?>
    </p>
<?php endif; ?>
</div>
</div>

<script type="text/javascript">
jQuery(function(){
    /* Validate on Search form */
    $('#SearchIndexAddForm').submit(function(event){
        if($('#SearchSearch').val() == ''){
            $.sme.notify('notice', '请输入搜索关键字');
            return false;
        }
    });
    /* Search input box tool tip */
    $('input#SearchSearch, input#SearchIndexType').tooltip({
        position: 'center center',
        offset: [70, 0],
        tip: '#tooltip',
        lazy: false,
        effect: 'slide'
    }).dynamic({
        left: {
            direction: 'down',
            bounce: true
        }
    });
    /* tag cloud ajax loader */
    $('div#tag_cloud').hide().load($.sme.url.base+'tagging/tags/cloud/', function(){
        $('span.notifier').hide();
        $('ul.tags').css({width: '80%'});
    });
    $('a#load_tag_cloud').click(function(){
        $('div#tag_cloud').toggle();
    });
});
</script>